#include "netaddress.h"

#include "netlib.h"

namespace kxlua {

NetAddress::NetAddress(NetLib* lib) {
    lib_ = lib;
    name_ = "NetAddress";
    isOpen_ = false;
}

NetAddress::~NetAddress() {
}

const std::string& NetAddress::GetName() const {
    return name_;
}

bool NetAddress::Open() {
    if (!isOpen_) {
        luabind::module(lib_->GetLua().GetState()) 
        [
            luabind::class_<net::NetAddress>("NetAddress")
            .def(luabind::constructor<std::string, uint32_t>())
            .def("GetIp", &net::NetAddress::GetIp)
            .def("GetSIp", &net::NetAddress::GetSIp)
            .def("GetPort", &net::NetAddress::GetPort)
        ];
        isOpen_ = true;
    }
    return true;
}

bool NetAddress::Close() {
}

}
